package com.wn.utils;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

/**
 * @author yellow Docter
 * @date 2024 -06-21
 * @desc
 */
public class CountTest {

    public static void main(String[] args) {

        Connection conn = JdbcUtil.getConnection();
        //02  准备sql
        String sql = "select count(*) from owner";
        System.out.println("sql = " + sql);
        //03 拿到ps
        PreparedStatement ps = null;

        ResultSet rs = null;
        try {
            ps = conn.prepareStatement(sql);
            rs = ps.executeQuery();
            if (rs.next()) {
                int total = (int) rs.getInt(1);
                System.out.println("total = " + total);
            }

        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            JdbcUtil.close(rs, ps, conn);
        }

    }

}
